﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Cwing.UI.Controls;

namespace Cwing.UI.Validation
{
    public delegate ValidationResult PageCutomizeValidate(Page instance);

    public delegate ValidationResult ControlCustomizeValidate(Page page, Control instance);

    public delegate void ControlValidating(ValidatingEventArgs e, ValidationResult result);

    public delegate void ControlValidated(ValidateEventArgs e, ValidationResult result);

    public delegate void PageValidating(PageValidatingEventArgs args, ValidationResult result);

    public delegate void PageValidated(PageValidatedEventArgs args, ValidationResult result);

    public delegate void UserControlValidating(UserControlValidatingEventArgs args, ValidationResult result);

    public delegate void UserControlValidated(UserControlValidatedEventArgs args, ValidationResult result);

    public class ValidatingEventArgs : EventArgs
    {
        public Boolean Cancel
        {
            get;
            set;
        }

        public IValidation Control { get; set; }

    }

    public class ValidateEventArgs : EventArgs
    {
        public IValidation Control { get; set; }
    }

    public class PageValidatingEventArgs : EventArgs
    {
        public PageValidatingEventArgs()
        {
            Cancel = false;
        }

        public Page PageInstance { get; set; }

        public IValidation Control { get; set; }

        public Boolean Cancel { get; set; }

        public ErrorList MessageContainer { get; set; }
    }

    public class PageValidatedEventArgs : EventArgs
    {
        public ErrorList MessageContainer { get; set; }
        public Page PageInstance { get; set; }
    }

    public class UserControlValidatingEventArgs : EventArgs
    {
        public UserControlValidatingEventArgs()
        {
            Cancel = false;
        }

        public UserControl UserControlInstance { get; set; }

        public IValidation Control { get; set; }

        public Boolean Cancel { get; set; }
    }

    public class UserControlValidatedEventArgs : EventArgs
    {
        public UserControl UserControlInstance { get; set; }
    }
}
